package com.hhh.api.enums;

public enum ContentCategory {
    POLITICS("0", "政治"),
    DRUGS("1", "毒品"),
    PORNOGRAPHY("2", "色情"),
    GAMBLING("3", "赌博"),
    ILLEGAL("4", "违法");

    // 枚举类的字段
    private final String code;
    private final String description;

    // 枚举类的构造函数
    ContentCategory(String code, String description) {
        this.code = code;
        this.description = description;
    }

    // 获取分类的编号
    public String getCode() {
        return code;
    }

    // 获取分类的描述
    public String getDescription() {
        return description;
    }

    // 根据编号获取对应的枚举常量
    public static ContentCategory getByCode(String code) {
        for (ContentCategory category : ContentCategory.values()) {
            if (category.getCode().equals(code)) {
                return category;
            }
        }
        throw new IllegalArgumentException("Invalid code: " + code);
    }
}